package com.invest.infra.mvc.utils;

import com.google.common.collect.Lists;
import com.google.common.collect.Maps;

import java.io.Serializable;
import java.util.List;
import java.util.Map;

public class MvcResult implements Serializable{

	/**
	 * 
	 */
	private static final long serialVersionUID = -7633391568565975882L;

	private Boolean hasError = false;

	// FORM表单错误
	private final Map<String,String> fieldErrors = Maps.newHashMap();

	//全局错误
	private final List<String> globalErrors = Lists.newArrayList();

	// 扩展结果
	private Object extObj;

	public void addFieldError(String id,String msg){
		hasError =true;
		fieldErrors.put(id,msg);
	}

	public void addGlobalError(String msg){
		hasError =true;
		globalErrors.add(msg);
	}
	public void addAllGlobalError(List<String> msgs){
		hasError =true;
		globalErrors.addAll(msgs);
	}

	public Object getExtObj() {
		return extObj;
	}

	public void setExtObj(Object extObj) {
		this.extObj = extObj;
	}

	public boolean hasError() {
		return hasError;
	}

	public Map<String, String> getFieldErrors() {
		return fieldErrors;
	}

	public List<String> getGlobalErrors() {
		return globalErrors;
	}


}

